package org.madgecko.api.dao.impl;

import org.madgecko.api.dao.iface.IRecordDao;
import org.madgecko.api.model.Record;
import org.madgecko.basic.dao.BaseDao;
import org.madgecko.basic.model.Pager;
import org.springframework.stereotype.Repository;

/**
 * Author       : MadFrog
 * Date         : 2019/6/16 16:32
 * Description  :
 */
@Repository
public class RecordDao extends BaseDao<Record> implements IRecordDao {

    @Override
    public Pager<Record> findByMember(Integer memberId) {
        String hql = "from Record r where r.member.id=" + memberId + " order by startTime desc";
        return this.find(hql);
    }

    @Override
    public Long countRecordByMember(Integer memberId) {
        String hql = "select count(*) from Record r where r.member.id=" + memberId;
        return (Long) this.queryObject(hql);
    }
}
